/* 
 * File:   movingcreaturetest.cpp
 * Author: dolphinigle
 *
 * Created on March 12, 2011, 6:37 PM
 */

#include <stdlib.h>
#include "gtest/gtest.h"
#include "direction.hpp"
#include "player.hpp"
#include "movingcreature.hpp"
#include "game.hpp"

TEST(MovingCreatureTest, All) {

  Game* game = new Game("Irvan", "test.gag");
  MovingCreature* mc = new Player(game);

  mc->setDirection(kUp);
  EXPECT_EQ(mc->getDirection(), kUp);

  for (int i = 0; i < 3; ++i) {
    mc->turnLeft();
    EXPECT_NE(mc->getDirection(), kUp);
  }
  mc->turnLeft();
  EXPECT_EQ(mc->getDirection(), kUp);

  for (int i = 0; i < 3; ++i) {
    mc->turnRight();
    EXPECT_NE(mc->getDirection(), kUp);
  }
  mc->turnRight();
  EXPECT_EQ(mc->getDirection(), kUp);

  for (int i = 0; i < 4; ++i) {
    if (mc->canMove()) {
      EXPECT_TRUE(game->getMaps()->getCellInFrontOff(mc->getCell(),
              mc->getDirection())->isSteppable());
      Cell* old_cell = mc->getCell();
      mc->move();
      EXPECT_NE(mc->getCell(), old_cell);
    }
    mc->turnLeft();
  }

  delete mc;
  delete game;

}

